<?php


namespace App\Models\Admin;



use App\Log\CompanyTypeLog;

class CompanyType extends Base
{
    const OPERATE_PID = 1;
    const MODEL = 'company_type';

    protected $table = 'company_type';
    protected $guarded = [];
    public $timestamps = false;

    public function product()
    {
         return  $this->hasMany(AdminProduct::class,'company_type','id');
    }

    public static function addLog($pre,$next,$type,$method='')
    {
        $info = AdminOperateModule::where('pid',self::OPERATE_PID)->where('type',$type)->where('model',self::MODEL)->when($method,function ($query)use ($method){
            $query->where('method',$method);
        })->first();
        if (!empty($info)){
            $adminLog = new CompanyTypeLog($pre,$next,$info);
            $adminLog->addLog();
        }
    }
}
